﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ERP_RORZE_DLL.Product.DAO;
using ERP_RORZE_DLL.Product.database;
using ERP_RORZE_DLL.Product.Base;

namespace ERP_RORZE_PRODUCT.Product.PartHandling
{
    public partial class ctrlBusInspMisReturnDetail : DevExpress.XtraEditors.XtraUserControl
    {
        ClsPartHandlingDAO clsDAO = new ClsPartHandlingDAO();
        ClsDMBusInspTable clsobj = new ClsDMBusInspTable();
        DataTable dt;

        public ctrlBusInspMisReturnDetail()
        {
            InitializeComponent();
        }
        void Reload(object sender, EventArgs e)
        {
            dt = clsDAO.GetAllBusInspMisReturnDetail();
            gridControl1.DataSource = dt;
            gridView1.BestFitColumns();
        }
        private void btnReload_Click(object sender, EventArgs e)
        {
            Reload(sender, e);
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            clsobj.ID = int.Parse(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ID").ToString());
            clsDAO.DeleteBusInspMisReturnDetail(clsobj);
            Reload(sender, e);
        }

        private void gridControl1_Load(object sender, EventArgs e)
        {
            Reload(sender, e);
        }

        private void btnInput_Click(object sender, EventArgs e)
        {
            frm_BusInspMisReturnInput frmAdd = new frm_BusInspMisReturnInput();
            frmAdd.Reload += new EventHandler(Reload);
            frmAdd.ShowDialog();
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {
            Reload(sender, e);
        }

        private void btnAddNew_Click(object sender, EventArgs e)
        {
            btnInput_Click(sender, e);
        }

        private void btDelete_Click(object sender, EventArgs e)
        {
            btnDelete_Click(sender, e);
        }

        private void btnExport_Click(object sender, EventArgs e)
        {
            clsConstantsFuction.ExportToExcel(gridView1, 1, true);
        }
    }
}
